import {
	baseUrl
}
from './base.js'

export const myRequest = (option) => {
	console.log(baseUrl)
	// const token = uni.getStorageSync("token") || '';
	// const Authorization = token ? `Bearer ${uni.getStorageSync("token")}` : "";
	uni.showLoading({
		title: "加载中",
		mask: true
	});
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl.baseUrl + option.url,
			method: option.method,
			data: option.data || {},
			header: {
				'Authorization': 'Bearer zhangkai:temp'
			},
			success(res) {
				// 可根据响应状态码进行操作
				// if (res.data.meta.status !== 200) {
				// 	return uni.showToast({
				// 		title: res.data.msg
				// 	})
				// }
				return uni.showToast({
					title: "请求接口成功"
				})
				resolve(res)
				return res

			},
			fail(err) {
				console.log(err);
				return uni.showToast({
					title: "请求接口失败"
				})
				reject(err)
			},
			complete() {
				uni.hideLoading();
			}
		})
	})
}
